package com.example.demo.common.vo;

import com.example.demo.common.enums.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author ccubee
 * @since 20-7-18 13:00
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseVo<T> {

    private Integer code;

    private String msg;

    private T data;


    public static <T> ResponseVo<T> success(){
        return new ResponseVo<T>(ResultEnum.OK.getCode(), ResultEnum.OK.getMsg(), null);
    }

    public static <T> ResponseVo<T> success(T data){
        return new ResponseVo<T>(ResultEnum.OK.getCode(), ResultEnum.OK.getMsg(), data);
    }

    public static <T> ResponseVo<T> isFail(){
        return new ResponseVo<T>(ResultEnum.FAIL.getCode(), ResultEnum.FAIL.getMsg(), null);
    }

}
